package com.gm.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gm.bean.Admin;
import com.gm.mapper.AdminMapper;
import com.gm.mapper.UserMapper;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

@Controller
public class UserController {
    @Autowired
    UserMapper userMapper;
    @GetMapping("/users")
    public String findAll(@RequestParam(defaultValue = "1") Integer page,
                          @RequestParam(defaultValue = "5") Integer size,
                          Model model){
        PageHelper.startPage(page,size);
        List<User> userList = this.userMapper.findUserAll(page,size);
        PageInfo<User> pageInfo = new PageInfo<>(userList);
        model.addAttribute("users",pageInfo);
        return "user-list";
    }
}
